/** 普通话我的成绩*/
<template>
  <div>
      <el-card shadow="never" v-loading="loading" body-style="padding: 24px;" class="card-margin">
        <h1 class="condition-title">{{$t('myScore.myScore')}}</h1>
        <edu-table :pagination="false" :selection='false' :tooltipEffect="tooltipEffect" stripe :data="dataList" size="mini">
          <edu-table-column :label="$t('myScore.name')" prop="studentName"></edu-table-column>
          <edu-table-column :label="$t('myScore.registraNumber')" prop="cardNo"></edu-table-column>
          <!-- <edu-table-column :label="$t('myScore.testTime')" prop="title"></edu-table-column> -->
          <edu-table-column :label="$t('myScore.testTime')" prop="examTime">
            <!-- <template slot-scope="scope">
              {{ scope.row.signUpStart+'/'+scope.row.signUpEnd}}
            </template> -->
          </edu-table-column>
          <edu-table-column :label="$t('myScore.performance')" prop="score"></edu-table-column>
          <edu-table-column :label="$t('myScore.grade')" prop="scoreRank"></edu-table-column>
        </edu-table>
        <el-row type="flex" class="row-bg" justify="end">
          <el-col>
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="queryForm.pageNum_"
                :page-sizes="[20, 40, 80, 100]"
                :page-size="queryForm.pageSize_"
                layout="total, sizes, prev, pager, next, jumper"
                :total="queryForm.total_"
                style="float:right;margin-top:10px"
              ></el-pagination>
          </el-col>
        </el-row>
      </el-card>
      
  </div>
</template>
<script>
// import HistoryTable from 'common/src/views/studentsRegistStudent/component/HistoryTable';
import { queryDic } from "common/src/api/dictionary";
import UTILS from "common/src/utils/utils";
import subjectCompetitionApi from 'common/src/api/subjectCompetition/subjectCompetition';
export default {
  data() {
    return{
      dataFormList: {}, //接收路由跳转的数据
      dataForm: {
        
      }, //表格数据
      internship: {
        opinion: ''
      },
      remark: '',
      myRaidersId: '',
      dataList: [
        // {
        //   calendarName: '测试',
        //   status: 0,
        //   testTime: '2020-07-13 15:30:00'
        // },
        // {
        //   calendarName: '测试',
        //   status: 1,
        //   testTime: '2020-07-13 09:30:00'
        // },
      ],
      dialogVisibleTime: false,
      forbidden: false,
      dataTime: new Date(),
      dialogVisible: false,
      outsideAdvisorId: '',
      curCheckStandard: '',
      curPracticeId: '',
      queryForm: {
        pageNum_: 1,
        pageSize_: 20,
        total_: 0,
        condition: {
          studentId: "",
          examCategory: "2"
        }
      },
      tableData: []
    }
  },
  filters: {
    collegeAcademyList(val, array) {
      let str = "";
      for (let item of array) {
        if (val === item.value) {
          str = item.label;
        }
      }
      return str;
    }
  },
  watch: {
    showFlag: {
      handler: function(newV, oldV) {
        if (newV) {
          // this.dataForm = this.$route.query.data;
          // this.tableData = this.$route.query.list;
        }
      }
    }
  },
  mounted() {
    this.getQueryPractice(this.queryForm);
  },
  created() {
    
  },
  methods: {
    // 下载
    download (path) {
      downloadfile(path);
    },
    getQueryPractice(data) {
      subjectCompetitionApi.computerMyGrades(data).then(res => {
        this.dataList = res.data.list;
        this.queryForm.total_ = res.data.total_;
        this.dataTime = new Date(); 
        let dateYear = this.dataTime.getFullYear();             //获取年 
        let dateMonth = this.dataTime.getMonth() + 1;               //获取月  
        let dateDate = this.dataTime.getDate();                 //获取当日
        // let dateDay = date.getDay();                   //获取当日星期数
        let dateHours = this.dataTime.getHours();               //获取小时
        let dateMinutes = this.dataTime.getMinutes();           //获取分钟
        let dateSeconds = this.dataTime.getSeconds();           //获取秒
        // 2020-7-13 11:30:00
        dateMonth = dateMonth >= 10 ? dateMonth : '0' + dateMonth;
        dateDate = dateDate >= 10 ? dateDate : '0' + dateDate;
        dateHours = dateHours >= 10 ? dateHours : '0' + dateHours;
        dateMinutes = dateMinutes >= 10 ? dateMinutes : '0' + dateMinutes;
        dateSeconds = dateSeconds >= 10 ? dateSeconds : '0' + dateSeconds;
        let timeDate = dateYear + '-' + dateMonth + '-' + dateDate + ' ' + dateHours + ':' + dateMinutes + ':' + dateSeconds;
        if (this.dataList) {
          this.dataList.forEach(el => {
            if (el.signUpEnd < timeDate) {
              el.forbidden = true;
            } else {
              el.forbidden = false;
            }
          });
        }
      });
    },
    getOptions() {
      // 筛选条件字典查询
      let data = {
        lang: this.$store.getters.language || "cn",
        type: "allChild",
        keys: ["X_YX", 'G_XBIE', "JDJB",]
      };
      queryDic(data).then(res => {
        UTILS.fillSelect(
          {
            facultys: "X_YX",
            degreeType: "JDJB",
            sex:"G_XBIE"
          },
          res.data,
          this.options
        );
        // console.log(this.options);
        
      });
    },
    // 报名
    myRaiders(val) {
      let dataTime = new Date(); 
      let dateYear = dataTime.getFullYear();             //获取年 
      let dateMonth = dataTime.getMonth() + 1;               //获取月  
      let dateDate = dataTime.getDate();                 //获取当日
      // let dateDay = date.getDay();                   //获取当日星期数
      let dateHours = dataTime.getHours();               //获取小时
      let dateMinutes = dataTime.getMinutes();           //获取分钟
      let dateSeconds = dataTime.getSeconds();           //获取秒
      // 2020-7-13 11:30:00
      dateMonth = dateMonth >= 10 ? dateMonth : '0' + dateMonth;
      dateDate = dateDate >= 10 ? dateDate : '0' + dateDate;
      dateHours = dateHours >= 10 ? dateHours : '0' + dateHours;
      dateMinutes = dateMinutes >= 10 ? dateMinutes : '0' + dateMinutes;
      dateSeconds = dateSeconds >= 10 ? dateSeconds : '0' + dateSeconds;
      let timeDate = dateYear + '-' + dateMonth + '-' + dateDate + ' ' + dateHours + ':' + dateMinutes + ':' + dateSeconds;
      if (val.signUpStart > timeDate) {
        this.dialogVisibleTime = true
      } else {
        this.remark = val.remark;
        this.myRaidersId = val.id;
        this.dialogVisible = true;
      }
      
    },
    reliable() {
      let obj = {
        id: this.myRaidersId,
        status: 1
      };
      subjectCompetitionApi.postUpdate(obj).then(res => {
        this.$message({
          type: 'success',
          message: this.$t('studentsRegist.successfully')
        });
          this.queryForm.pageNum_ = 1;
          this.getQueryPractice(this.queryForm);
          this.dialogVisible = false;
      });
      
    },
    // 取消报名
    cancelRegistr(val) {
      this.$confirm(this.$t('studentsRegist.registration'), this.$t('studentsRegist.cancelRegistr'), {
          confirmButtonText: this.$t('studentsRegist.confirm'),
          cancelButtonText: this.$t('studentsRegist.cancel'),
          type: 'warning'
        }).then(() => {
          let obj = {
            id: val.id,
            status: 0
          };
          subjectCompetitionApi.postUpdate(obj).then(res => {
            this.queryForm.pageNum_ = 1;
            this.getQueryPractice(this.queryForm);
          });
          // this.$message({
          //   type: 'success',
          //   message: this.$t('studentsRegist.successfully')
          // });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: this.$t('studentsRegist.canceled')
          });          
        });
    },
    handleSizeChange(val) {
      this.queryForm.pageSize_ = val;
      this.queryForm.pageNum_ = 1;
      this.getQueryPractice(this.queryForm);
    },
    handleCurrentChange(val) {
      this.queryForm.pageNum_ = val;
      this.getQueryPractice(this.queryForm);
    },
    // 驳回
    reject() {
      if (this.internship.opinion.indexOf("$") < 0) {
        if (this.internship.opinion) {
          let practiceIds = [];
          practiceIds.push({
            no: this.$route.query.data.actNo,
            content: this.internship.opinion
          });
          studentsRegistStudent.internshipRefuse(practiceIds).then((data) => {
            this.$message({
                type: "success",
                message: this.$t('identificationToDoList.SuccessfulOperation')
            });
            this.goBack();
          });
        } else {
          this.$message({
              type: "error",
              message: this.$t('myExamine.reviewComments')
          });
        }
      } else {
        this.$message({
            type: "error",
            message: this.$t('identificationToDoList.cannotContain')
        });
      }
    },
    // 通过
    pass() {
      // 
      if (this.internship.opinion.indexOf("$") < 0) {
        let practiceIds = [];
        practiceIds.push({
          no: this.$route.query.data.actNo,
          content: this.internship.opinion
        });
        studentsRegistStudent.internshipAgree(practiceIds).then((data) => {
          this.$message({
              type: "success",
              message: this.$t('identificationToDoList.SuccessfulOperation')
          });
          this.goBack();
        });
      } else {
        this.$message({
            type: "error",
            message: this.$t('identificationToDoList.cannotContain')
        });
      }
    },
    goBack() {
      this.$store.commit("delete_tabs", this.$route.path);
      this.$router.go(-1);
    },
    // 获取表格数据
    assignment() {
    
    },
  },
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.inner-breadcrumb {
    .breadcrumb {
        span {
            font-weight: normal;
            color: #aaa;
        }
        a {
            font-weight: normal;
            color: #aaa;
        }
        a:hover {
            color: #409eff;
        }
        .last {
            font-weight: bold !important;
            cursor: default !important;
        }
        .disable {
            cursor: default !important;
        }
    }
}
.condition-title-p {
    font-weight: 400;
    font-style: normal;
    color: #2b3b4e;
    font-size: 18px;
    margin-bottom: 15px;
}
.base-info-title {
    font-weight: 400;
    font-style: normal;
    font-size: 16px;
    color: #2b3b4e;
}
.table-style-baseinfo {
    background-color: rgba(210, 212, 214, 1);
    box-sizing: border-box;
    border-width: 0.5px;
    border-style: solid;
    border-color: rgba(210, 212, 214, 1);
    border-radius: 0px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    width: 100%;
    font-weight: 401;
    font-style: normal;
    font-size: 14px;
    color: #8896a7;
    margin-bottom: 20px;
}

.table-style-baseinfo td {
    width: 25%;
    background-color: rgba(255, 255, 255, 1);
    border: none;
    border-radius: 0px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    font-weight: 401;
    font-style: normal;
    font-size: 14px;
    color: #2b3b4e;
    height: 32px;
    padding: 0 10px;
}

.table-style-baseinfo .text-right-background-color {
    background-color: #fdfeff4d;
    text-align: right;
}

.text-left-background-none {
    text-align: left;
}
</style>